﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Distribution.Dto
@model TotalSummaryReceivableDto
@{
    Layout = null;
    decimal SumDistributionPrice = 0m;

    decimal SumTotalPrice = 0m;
    decimal SumTotalDiscount = 0m;
    decimal SumUsePrePayment = 0m;
    decimal SumReceivedPrice = 0m;
    decimal SumNotActualprice = 0m;



    int SumDistributionCount = 0;
    int SumRecoveryCount = 0;
    int SumGiveCount = 0;
    int SumExchangegoodsCount = 0;

    int i = 0;
    if (Model.PageList.Count > 0)
    {
        if (Model.PageList.PageNumber != 1)
        {

            i = (Model.PageList.PageNumber - 1) * Model.PageList.PageSize;
        }
    }
    int count = 0;
}
<div id="table_print" style="max-height:600px;overflow-y:scroll;">
    @if (Model.PageList.Count == 0)
    {
        <h4>暂无数据</h4>
    }
    else
    {
        <table class="table table-bordered table-hover table-rowselected">
            <thead>
                <tr>
                    <th style="width:45px">序号</th>
                    <th>餐厅名称</th>
                    <th>配送金额</th>
                    <th>总优惠</th>
                    <th>折扣率</th>
                    <th>应收金额</th>
                    <th>已收金额</th>
                    <th>未收金额</th>
                    <th>预收金额</th>
                    <th>商品名称</th>
                    <th>配送数量</th>
                    <th>回收数量</th>
                    <th>赠送数量</th>
                    <th>换货数量</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.PageList)
                {

                    count = item.SummaryDistributions.Count;
                    int j = 0;
                    foreach (var distributions in item.SummaryDistributions)
                    {
                        i++;
                        <tr>
                            <td>@i</td>
                            @if (j == 0)
                            {
                                <td rowspan="@count">@item.RestaurantName</td>
                                <td rowspan="@count">@item.DistributionPrice</td>//配送
                                <td rowspan="@count">@item.TotalDiscount</td>
                                <td rowspan="@count">@item.DiscountRate</td>
                                <td rowspan="@count">@item.TotalPrice</td>
                                <td rowspan="@count">@item.ReceivedPrice</td>
                                <td rowspan="@count">@item.NotActualprice</td>
                                <td rowspan="@count">@item.UsePrePayment</td>
                                <td>@distributions.TypeNumberName</td>
                                <td>@distributions.DistributionCount</td>
                                <td>@distributions.RecoveryCount</td>
                                <td>@distributions.GiveCount</td>
                                <td>@distributions.ExchangegoodsCount</td>
                            }
                            else
                            {
                                <td>@distributions.TypeNumberName</td>
                                <td>@distributions.DistributionCount</td>
                                <td>@distributions.RecoveryCount</td>
                                <td>@distributions.GiveCount</td>
                                <td>@distributions.ExchangegoodsCount</td>
                            }
                        </tr>
                        //SumDistributionCount += distributions.DistributionCount;
                        //SumRecoveryCount += distributions.RecoveryCount;
                        //SumGiveCount += distributions.GiveCount;
                        //SumExchangegoodsCount += distributions.ExchangegoodsCount;
                        j++;
                    }
                    //SumDistributionPrice += item.DistributionPrice;
                    //SumTotalPrice += item.TotalPrice;
                    //SumReceivedPrice += item.ReceivedPrice;
                    //SumTotalDiscount += item.TotalDiscount;
                    //SumUsePrePayment += item.UsePrePayment;
                    //SumNotActualprice += item.NotActualprice;


                }
                @*<tr class="footer">
                        <td></td>
                        <td style="color:red">该页小计</td>
                        <td style="color:red">@SumDistributionPrice</td>
                        <td style="color:red">@SumTotalDiscount</td>
                        <td style="color:red">@((Convert.ToDouble(SumTotalDiscount) / Convert.ToDouble(SumDistributionPrice)).ToString("0.00%"))</td>
                        <td style="color:red">@SumTotalPrice</td>
                        <td style="color:red">@SumReceivedPrice</td>
                        <td style="color:red">@SumNotActualprice</td>
                        <td style="color:red">@SumUsePrePayment</td>
                        <td></td>
                        <td style="color:red">@SumDistributionCount</td>
                        <td style="color:red">@SumRecoveryCount</td>
                        <td style="color:red">@SumGiveCount</td>
                        <td style="color:red">@SumExchangegoodsCount</td>
                    </tr>*@
                <tr class="footer" style="background-color:darkgray">
                    <td colspan="2" style="color:red;text-align:center">总合计</td>
                    <td style="color:red">@Model.TotalDistributionPrice</td>
                    <td style="color:red">@Model.TotalDiscountPrice</td>
                    <td style="color:red">@((Convert.ToDouble(Model.TotalDiscountPrice) / Convert.ToDouble(Model.TotalDistributionPrice)).ToString("0.00%"))</td>
                    <td style="color:red">@Model.TotalSummaryPrice</td>
                    <td style="color:red">@Model.TotalReceivedPrice</td>
                    <td style="color:red">@Model.TotalNotActualprice</td>
                    <td style="color:red">@Model.TotalUsePrePayment</td>
                    <td></td>
                    <td style="color:red">@Model.TotalDistributionCount</td>
                    <td style="color:red">@Model.TotalRecoveryCount</td>
                    <td style="color:red">@Model.TotalGiveCount</td>
                    <td style="color:red">@Model.TotalExChangedCount</td>
                </tr>
            </tbody>
        </table>
    }
</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        @*共 @Model.PageList.TotalItemCount 条，@Model.PageList.PageSize 条/页 当前第 @Model.PageList.PageNumber/@Model.PageList.PageCount 页*@
        共 @Model.PageList.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageList.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp;条/页 当前第 @Model.PageList.PageNumber/@Model.PageList.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&keyword=@(Context.Request.Query["keyword"])&beginTime=@(Context.Request.Query["beginTime"])&endTime=@(Context.Request.Query["endTime"])" />
        @Html.PagedListPager(Model.PageList, page => Url.Action("Summary", new { pageIdx = page, size = Context.Request.Query["size"], keyword = Context.Request.Query["keyword"], beginTime = Context.Request.Query["beginTime"], endTime = Context.Request.Query["endTime"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>

